package com.she.olympic;

import com.she.olympic.R;

import com.adon.ar.test.ARExampleActivity;

import android.app.Activity;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

public class MessageGiftActivity extends Activity {

	private ImageView mail, back;
	private TextView Textgoldcode;
	private String msgGiftPageGoldcode;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		this.requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.by_msg_gift_page);

		mail = (ImageView) findViewById(R.id.msg_gift_page_mailme);
		back = (ImageView) findViewById(R.id.msg_gift_page_back);
		Textgoldcode = (TextView) findViewById(R.id.msg_gift_page_goldcode);
		
		Olympic olympic = (Olympic) getApplicationContext();
		msgGiftPageGoldcode = olympic.getGiftPageGoldcode();
		Textgoldcode.setText(olympic.getGiftPageGoldcode());
		
		mail.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
							
            	Intent sendIntent = new Intent(Intent.ACTION_VIEW);
            	sendIntent.setClassName("com.google.android.gm", "com.google.android.gm.ComposeActivityGmail");
//            	sendIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { "abc@gmail.com" });
            	sendIntent.setData(Uri.parse("abc@gmail.com"));
            	sendIntent.putExtra(Intent.EXTRA_SUBJECT, "中華加油照集令-金牌抽獎序號");
            	sendIntent.setType("plain/text");
            	sendIntent.putExtra(Intent.EXTRA_TEXT, "親愛的中華電信客戶：\n\n讚！你的十次加油，選手句句感動接收。你助中華得金牌，中華電信也送你金牌。享有金牌密碼，" 
            											+ "週週樂抽金牌得主！\n\n這是您的金牌密碼：\n"
            											+ msgGiftPageGoldcode
            											+ "\n\n\n註：請務必保留金牌密碼電子郵件，以作後續領獎證明使用！");
            	startActivity(sendIntent);
				
			}
		});
		
		back.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				((Olympic)MessageGiftActivity.this.getApplication()).mPageIndex = Olympic.PageIndex.TREE_CONTESTANY; // back to TREE_CONTESTANY
				MessageGiftActivity.this.finish();
				System.gc();
			}
		});
	}

	@Override
	public void onBackPressed() {
		((Olympic)MessageGiftActivity.this.getApplication()).mPageIndex = Olympic.PageIndex.TREE_CONTESTANY; // back to TREE_CONTESTANY
		MessageGiftActivity.this.finish();
		super.onBackPressed();
	}
}
